package com.bwie.lib_core.network.interceptor;

import com.blankj.utilcode.util.SPStaticUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * token拦截器
 * */
public class TokenInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        //获取request->网络请求->TOKENKEY判断是否使用token
        Request request = chain.request();
        Request.Builder builder = request.newBuilder();
        builder.url(request.url());
        builder.headers(request.headers());
        builder.addHeader("token", SPStaticUtils.getString("token"));
        builder.post(request.body());
        return chain.proceed(builder.build());
    }
}
